package VisibleForTesting知识;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class CalculatorTest {

    @Test
    public void testCalculateSquareRoot() {
        // 创建 Calculator 对象
        Calculator calculator = new Calculator(25);

        // 调用 calculateSquareRoot 方法，验证它的行为
        int result = calculator.calculateSquareRoot(16);

        System.out.println(result);
        // 验证结果是否正确
        assertEquals(4, result, "Square root of 16 should be 4");

        // 验证负数输入时抛出异常
        assertThrows(IllegalArgumentException.class, () -> calculator.calculateSquareRoot(-1),
                "Negative numbers should throw an exception");
    }
}

